In computer graphics, we distinguish between Vector and Bitmap graphics. Vector graphics (like SVG) describe images through logical shapes; every element is a persistent object in the DOM. Conversely, Bitmap graphics (like HTML5 Canvas) work with rasters of colored dots.
1. The Transition to Canvas
While SVG is easier to style via CSS, the browser must track every node. For high-performance needs, like games with thousands of moving parts, the Canvas API is superior. It provides a single DOM element that encapsulates a drawing surface—essentially a "blank slate."
2. The Drawing Context
The <canvas> element is a "black box" until we initialize its context. This object's methods provide the actual drawing interface, decoupling the display element from the rendering logic.
3. Namespace Awareness
In XML-based graphics like SVG, the xmlns="http://www.w3.org/2000/svg" attribute is critical. It signals the browser to switch from standard HTML parsing to the specific graphics schema, allowing shape tags to be recognized as interactive objects.